package cn.util.baidu.ueditor.upload;
/**
 * 上传到阿里云：xhj
 *
 *
 */
import java.io.FileNotFoundException;
import java.io.InputStream;

import cn.util.aliyun.AliyunOSSClientUtil;
import com.aliyun.oss.OSSClient;
import org.springframework.beans.factory.annotation.Autowired;


public class UploadOSSUtil {

    public UploadOSSUtil(){}

    public static void uploadImgAliyun(InputStream inputStream ,String fileName)
            throws FileNotFoundException{
        String accesskeyId = AliyunOSSClientUtil.accessKeyId ;
        String accessKeySecret = AliyunOSSClientUtil.accessKeySecret ;
        String endpoint =AliyunOSSClientUtil.endpoint;
        String bucketName = AliyunOSSClientUtil.bucketName;
        OSSClient client = new OSSClient(endpoint,accesskeyId,accessKeySecret);
        //此处"images/companyNewsImages/"+fileName,表示上传至阿里云中images文件夹下的companyNewsImages文件夹中，请修改为自己的路径即可
        client.putObject(bucketName, "images/companyNewsImages/"+fileName, inputStream);
        client.shutdown();
    }
}
